/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package _4_Mapper;

import _3_Object.CreateAccountObject;
import _5_DB.ConnectDB;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author DOM
 */
public class CreateAccountMapper {
   public static CreateAccountObject cao (CreateAccountObject c)
   {
       try{
           ConnectDB db = new ConnectDB();
           Connection con = db.getConnection();
           
           CallableStatement proc = null;
           proc = con.prepareCall("{call procTaoAcc(?,?,?,?,?,?,?,?)}");
           
           proc.setString(1, c.getNick());
           proc.setString(2, c.getName());
           proc.setString(3, c.getBirth());
           proc.setString(4, c.getEmail());
           proc.setString(5, c.getPhone());
           proc.setString(6, c.getPass());
           proc.setString(7, c.getAbout());
           proc.setInt(8, c.getSex());
           
           ResultSet rs = proc.executeQuery();
           if(rs.next())
           {
               c.setNick(rs.getString("nick"));
               c.setName(rs.getString("name"));
               c.setBirth(rs.getString("birth"));
               c.setEmail(rs.getString("email"));
               c.setPhone(rs.getString("phone"));
               c.setPass(rs.getString("pass"));
               c.setAbout(rs.getString("about"));
               c.setSex(rs.getInt("sex"));
           }
       }
       catch(SQLException ex)
       {
           
       }
       return c;
   }
}
